<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    
<!-- header -->
<jsp:include page="../include/header.jsp"></jsp:include>
	<header id="header">

	<!--/header-middle-->
	<jsp:include page="../include/header_middle.jsp"></jsp:include>		
	
	<!--header-bottom-->
	<jsp:include page="../include/header_bottom.jsp"></jsp:include>	
	<!--/header-bottom-->
	
	</header>
	<!--/header-->
	
	<section>
		<div class="container">
			<div class="row">
				<div class="col-sm-2">
					
				</div>
				
				<div class="col-sm-9 padding-right">	
					<!--각자 삽입할 부분-->
					<center>
					<h1>주문 및 배송정보</h1>
					</center>
					
					<br/>
					
					<table class="table table-bordered">
					<tr align="center">
							<td colspan="2" bgcolor="#fe980f"><h4 style="font-weight: bold; color: white;">결제 정보</h4></td>
						</tr>
					<tr align="center">	
					<td>결제금액</td>
					<td><fmt:formatNumber value="${ beans.orders_price }" pattern=",###"/>원</td>
					</tr>
					<tr align="center"> 
					<td>주문일</td>
					<td>${ beans.orders_date }</td>
					</tr>
					<tr align="center">
					<td>주문번호</td>
					<td>${ beans.orders_no }</td>
					</tr>
					<tr align="center">
					<td>결제수단</td>
					<td>${ beans.orders_payments }</td>
					</tr> 
					<tr align="center">
					<td>요청사항</td>
					<td>${ beans.orders_msg }</td>
					</tr>
					</table>
					
					<br/>
					
					<table class="table table-bordered">
						<tr align="center">
							<td colspan="5" bgcolor="#fe980f"><h4 style="font-weight: bold; color: white;">주문 상품 정보</h4></td>
						</tr>
						<!-- 
						<tr align="center" bgcolor="#EEE">
							<td>제품명</td>
							<td>가격</td>
							<td>수량</td>
							<td>합계</td>
							<td>적립금</td>
						</tr>
						 -->
					<!-- c:for로 돌리면서 html문 작성 -->
					<c:forEach items="${ details }" var="details">
						<tr align="center">
								<c:forEach items="${ product }" var="product">
									<c:if test="${details.odetail_product.equals(product.product_no)}">
										<td>${ product.product_name }</td>
										<td><fmt:formatNumber value="${ product.product_price }" pattern=",###"/>원</td>
									</c:if>
								</c:forEach>
							<td>${ details.odetail_count }개</td>
							<c:forEach items="${ product }" var="product">
									<c:if test="${details.odetail_product.equals(product.product_no)}">
										<td><fmt:formatNumber value="${ product.product_price * details.odetail_count }" pattern=",###"/>원</td>
										<td><fmt:formatNumber value="${ product.product_price * details.odetail_count / 20 }" pattern=",###"/>원 적립</td>
									</c:if>
								</c:forEach>
						</tr>
					</c:forEach>
					</table>				
					
					<br/>
					
					<!-- 추후 이미지로 대체 예정 -->	
					<table class="table table-bordered">
						<tr align="center">
							<td colspan="4" bgcolor="#fe980f"><h4 style="font-weight: bold; color: white;">수취인 정보</h4></td>
						</tr>
						<tr align="center">
							<td width="15%">이름</td>
							<td width="35%">${ beans.orders_name }</td>
							<td width="15%">E-Mail</td>
							<td width="35%">${ beans.orders_email }</td>
						</tr>
						<tr align="center">
							<td width="15%">전화번호</td>
							<td width="35%">${ beans.orders_phone }</td>
							<td colspan="2"></td>
						</tr>
						<tr align="center">
							<td width="15%">우편번호</td>
							<td width="35%">${ beans.orders_zip }</td>
							<td width="15%">기본주소</td>
							<td width="35%">${ beans.orders_addr1 }</td>
						</tr>
						<tr align="center">
							<td width="15%">상세주소</td>
							<td colspan="3">${ beans.orders_addr2 }</td>
						</tr>
					</table>
					<form id="f" name="f" method="post">
						<div align="center">
							<input type="button" class="btn btn-primary btn-lg" onclick="goToMain()" value="메인으로"/>
							<input type="button" class="btn btn-primary btn-lg" onclick="goToList()" value="주문 목록"/>
							<input type="button" class="btn btn-primary btn-lg" onclick="deleteOrder()" value="내역 삭제"/>
							<input type="hidden" name="o_no" value="${ beans.orders_no }"/>
						</div>
					</form>
					
					<br/>
					<br/>
					<br/>
					
					<!--삽입 끝 -->					
				</div>
			</div>
		</div>
	</section>
	
	<c:if test="${stat}">
		<script type="text/javascript">
			alert('주문 완료!');
		</script>
	</c:if>
	
	<script type="text/javascript">
		function goToMain(){
			document.f.action = "/ecom/";
			document.f.submit();
		}
		
		function goToList(){
			document.f.action = "/ecom/orders/list";
			document.f.submit();
		}	
		
		function deleteOrder(){
			document.f.action = "/ecom/orders/delete";
			document.f.submit();
		}
	</script>
	
	<!--Footer-->
	<jsp:include page="../include/footer.jsp"></jsp:include>
	<!--/Footer-->